package JUnit;

import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.stream.Stream;


@TestMethodOrder(MethodOrderer.OrderAnnotation.class)

public class JUnitTest {
    public static Stream<Arguments> generator() {
        return Stream.of(Arguments.arguments("1,小张", "2,小李"));
    }

    @Test
    void test1() {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.baidu.com/");
    }

    @ParameterizedTest
    @ValueSource(strings = {"1", "2", "3"})
    void test2(String s) {
        System.out.println(s);
    }

    @ParameterizedTest
    @CsvSource({"1,2", "3,4"})
    void test3(String s, int num) {
        System.out.println(s + " " + num);
    }

    @ParameterizedTest
    @CsvFileSource(resources = "test1.csv")
    void test4(int id, String name) {
        System.out.println("id = " + id + "name = " + name);
    }

    @ParameterizedTest
    @MethodSource("generator")
    void test5(String num, String name) {
        System.out.println(num + " " + name);
    }

    @Disabled
    @ParameterizedTest
    @ValueSource(strings = {"1"})
    void test6(String num){
        //断言相等
        Assertions.assertEquals(num,"1");
        //断言不相等
        Assertions.assertNotEquals(num,"1");
        //断言为空
        Assertions.assertNull(num);
        //断言不为空
        Assertions.assertNotNull(num);
    }

}
